package com.solutionsfit.timesheet.action

import static org.jboss.seam.ScopeType.CONVERSATION
import javax.persistence.Query
import com.solutionsfit.timesheet.Project
import com.solutionsfit.timesheet.GroovyTimesheet

import org.jboss.seam.annotations.Name
import org.jboss.seam.annotations.In
import org.jboss.seam.annotations.Out
import org.jboss.seam.annotations.Factory
import org.jboss.seam.annotations.Logger
import org.jboss.seam.annotations.Scope
import org.jboss.seam.annotations.datamodel.DataModel
import org.jboss.seam.log.Log

import javax.persistence.EntityManager

@Name("projectList")
@Scope(CONVERSATION)
class ProjectListAction {
	@Logger
	Log log
	
	@In
	EntityManager em
	
	@DataModel
	List<Project> projects
	
	@Factory("projectList")
	void loadProjects()
	{
		Query query = em.createQuery("select project from Project as project")
		projects = query.getResultList()
	}
}